package com.gexiaobao.pigeon.ui.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.model.bean.PigeonBean
import com.gexiaobao.pigeon.app.model.bean.UserAuthsInfoResponse
import com.gexiaobao.pigeon.app.model.bean.VisitMemberListResponse
import com.gexiaobao.pigeon.ui.adapter.AddTrainingFlyAdapter
import com.gexiaobao.pigeon.ui.adapter.UserForShedListAdapter
import com.gexiaobao.pigeon.ui.adapter.VisitMemberListAdapter
import me.hgj.jetpackmvvm.base.appContext

/**
 * @Author      : hxw
 * @Date        : 2024/6/6 14:25
 * @Describe    :
 */
class RxDialogShedList(context: Context?) : RxDialog(context!!) {

    private val mAdapter: UserForShedListAdapter by lazy { UserForShedListAdapter(arrayListOf()) }
    private lateinit var rvMember: RecyclerView
    private var mOnItemClickListener: OnItemClickListener? = null
    private lateinit var tvListDialogTitle: AppCompatTextView

    init {
        initView()
    }

    @SuppressLint("MissingInflatedId")
    private fun initView() {
        val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_visit_member, null)
        rvMember = dialogView.findViewById(R.id.rvMember)
        tvListDialogTitle = dialogView.findViewById(R.id.tvListDialogTitle)
        tvListDialogTitle.text = appContext.getString(R.string.selective_shed)

        rvMember.layoutManager = LinearLayoutManager(context)
        rvMember.adapter = mAdapter

        mAdapter.setOnItemClickListener { _, _, position ->
            mOnItemClickListener?.onItemClick(
                position,
                mAdapter.data[position].orgId,
                mAdapter.data[position].pair,
                mAdapter.data[position].visitVideo
            )
            dismiss()
        }

        setContentView(dialogView)
    }

    @SuppressLint("NotifyDataSetChanged")
    fun setAdapterData(data: ArrayList<UserAuthsInfoResponse.ListBean>) {
        mAdapter.setList(data)
        mAdapter.notifyDataSetChanged()
    }

    fun setOnClickListener(listener: OnItemClickListener?) {
        mOnItemClickListener = listener
    }

    interface OnItemClickListener {
        fun onItemClick(position: Int, id: Int, pair: Int, video: Int)
    }

}